#include "stdafx.h"
#include "Menu.h"
Menu::Menu(HWND hWnd){
	HMENU oldMenu = GetMenu(hWnd);
	if(oldMenu){
		DestroyMenu(oldMenu);
	}

	MenuBuilder mFile;
	mFile.CreateAsSub();
	mFile.AppendItem(L"file.new",		L"New\tCtrl+N");
	mFile.AppendItem(L"file.open",		L"Open\tCtrl+O");
	mFile.AppendItem(L"file.save",		L"Save\tCtrl+S");
	mFile.AppendItem(L"file.saveas",	L"Save As...");
	mFile.AppendItem(L"file.saveall",	L"Save All\tCtrl+Shift+S");
	mFile.AppendSeprator();
	mFile.AppendItem(L"file.exit",		L"Exit\tAlt+X");

	MenuBuilder mEdit;
	mEdit.CreateAsSub();
	mEdit.AppendItem(L"edit.copy",		L"Copy");
	mEdit.AppendItem(L"edit.cut",		L"Cut");
	mEdit.AppendItem(L"edit.paste",		L"Paste");
	mEdit.AppendSeprator();
	mEdit.AppendItem(L"edit.redo",		L"Redo");
	mEdit.AppendItem(L"edit.undo",		L"Undo");

	MenuBuilder mWindow;
	mWindow.CreateAsSub();
	mWindow.AppendItem(L"buffers.close",			L"Close");
	mWindow.AppendItem(L"buffers.closeother",		L"Close Other");
	mWindow.AppendItem(L"buffers.closeall",			L"Close All");
	mWindow.AppendSeprator();

	MenuBuilder mHelp;
	mHelp.CreateAsSub();
	mHelp.AppendItem(L"help.about",		L"About");

	menuBar.Create();
	menuBar.AppendSubMenu(L"File",		mFile);
	menuBar.AppendSubMenu(L"Edit",		mEdit);
	menuBar.AppendSubMenu(L"Window",	mWindow);
	menuBar.AppendSubMenu(L"Help",		mHelp);
	SetMenu(hWnd, menuBar);
	DrawMenuBar(hWnd);
}
